1. Field of the Invention
The present invention relates to an image processing program product and an image processing apparatus, and particularly to an image processing program product and an apparatus for performing Retinex processing as a part of processing effected on output images of digital cameras and film scanners.
2. Description of the Related Art
In a conventional field of image processing, a Center/Surround Retinex processing has been proposed as an image processing technology, in which functions of a retina and a cortex of a living body are substantially modeled (e.g., U.S. Pat. No. 5,991,456).
The Retinex processing is a method for correcting image information forming digital data. There are various modifications of the Retinex processing. In this specification, however, correction methods, in which the visual sensation is modeled and surrounding information with respect to a center pixel (i.e., pixel of interest) is taken into consideration, are collectively referred to as “Retinex processing”. Expanded Retinex to be described later is one of forms included in the Retinex processing. According to the Retinex processing, since gain adjustment locally changes in accordance with light and darkness in the image, an effect of compressing a dynamic range can be achieved.
In connection with Center/Surround Retinex algorithm, Single Scale Retinex (SSR) and Multi-Scale Retinex (MSR) have been known. Algorithm of the SSR and MSR will now be described.
The Single Scale Retinex (SSR) is expressed by the following formula (1). The processing in formula (1) is executed on each of R, G and B channels, and results are integrated to provide a color output image.Ti(x, y)=log Ii(x, y)−log{F(x, y)*Ii(x, y)}  (1)(i=R, G, B)where “*” represents a convolution integral. Ti(x, y) represents a pixel value after the SSR processing, and Ii(x, y) represents a pixel value of an original image. F(x, y) is a function used in a filter for producing a blurred image in view of pixels surrounding the center pixel. For example, F(x, y) may be a Gaussian function, in which case F(x, y) satisfies the following relationships (2) and (3).F(x, y)=K·exp{−(x2+y2)/c2}  (2)ΣΣF(x, y)=1  (3)where c represents a constant determining a peripheral spread in the Gaussian function, and is referred to as a kernel value. The constant K is determined to satisfy the formula (3). It is generally known that a smaller value of c increases an effect of edge enhancement in image processing, and a larger value of c increases an effect of dynamic range compression.
Clipping processing is performed for the purpose of improving a contrast in the output image subjected to the SSR processing. Usually, pixel values within lower and higher 3% ranges in a histogram distribution are clipped, and then are subjected to linear transformation to be assigned to digital values corresponding to the number of output bits (e.g., 8 bits).
FIG. 18 illustrates specific processing of SSR using the Gaussian function for producing a blurred image.
Referring to FIG. 18, processing is effected on an original image (processing target image) D2 having i=R, G and B. In FIG. 18, P2 indicates an image produced by combining R, G and B in the original image.
Each pixel value in D2 is represented as Ii(x, y). For producing a blurred image D4, an operation of Ii(x, y)*G(x, y) is performed. G(x, y) is a Gaussian function.
Processing is performed to divide each pixel value of the original image by the pixel value of the blurred image, and a logarithm of the result is obtained so that an image D5 subjected to the Retinex processing is obtained. Each pixel value of image D5 is represented by Ri(x, y). By combining images D5 formed of R, G and B, image P1 subjected to the Retinex processing is obtained.
According to the Multi-Scale Retinex (MSR), various different values are used as constant c in formula (2). Thereby, the SSR processing is performed with the Gaussian functions having different peripheral spreads. The respective results thus obtained are summed and averaged so that the edge enhancement and dynamic range compression are simultaneously achieved.
FIG. 19 illustrates the MSR processing using the Gaussian function.
Referring to FIG. 19, blurred images D4-1, D4-2 and D4-3 are produced based on original image D2, and more specifically are produced with a Gaussian function having a narrow peripheral spread (a filter of a small size), a Gaussian function having a medium peripheral spread (a filter of a medium size) and a Gaussian function having a wide peripheral spread (a filter of a large size), respectively.
Original image D2 is divided by the respective blurred images, and logarithms of the results are obtained to provide images D5-1-D5-3. A higher effect of edge enhancement is achieved in the image processed with a function of a small filter size, and a higher effect of dynamic range compression is achieved in the image processed with a function of a large filter size. By summing and averaging images D5-1-D5-3, the edge enhancement and dynamic range compression can be simultaneously achieved.
Study and research have been zealously conducted for applying the foregoing SSR and MSR processing to image data, which is produced in a digital form from negative films or the like by film scanners, and digital image data produced by digital still cameras.
Japanese Patent Laying-Open No. 2001-245154 discloses a technique, in which a large contrast difference between different regions in an image is reduced while maintaining a small contrast difference between different regions in the image.
“Improvement of Image Appearance by Modified Retinex Model”, Masaki Kobayashi and Hiroaki Kotera, transactions of Color Forum JAPAN 2001 (47th optical four institutions joint meeting, Nov. 13-15, 2001) discloses a technique, in which the Retinex processing is formed of linear operations.
The image processing techniques such as a conventional Center/Surround Retinex algorithm already described suffer from problems of:    shift of a whole tint in an image using colors shifted to a large extent, and    unnatural saturation of luminance in a bright region such as a face.
For overcoming the above problems, expanded Retinex processing techniques such as:    a manner in which information of the original image is added to an output image to a certain extent,    a manner in which Retinex processing is effected on only luminance information, and    a manner in which portions of certain luminance or higher in a blurred image already subjected to filtering with a Gaussian function is rounded,    have been proposed for suppressing the extreme shift of the tint and the unnatural luminance saturation in bright regions have been proposed.
According to the image processing techniques such as a conventional Center/Surround Retinex algorithm already described, calculation processing for producing a blurred image becomes heavy particularly when an original image has a high resolution. This results in problems of increase of memory consumption and lowering of processing speed.